//
//  SecondBarViewController.m
//  JiJinFinance
//
//  Created by 李东晓 on 15/12/1.
//  Copyright © 2015年 LiDongXiao. All rights reserved.
//

#import "SecondBarViewController.h"
#import "SecBarCollectionViewCell.h"
#import "SecModel.h"
#import "SecToViewController.h"
@interface SecondBarViewController ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property (nonatomic ,strong)NSMutableArray * dataArray;
@end

@implementation SecondBarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    self.title = @"我要理财";
    //自定义集金金融的大小
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    _dataArray = [[NSMutableArray alloc]init];
    
    [self CollectionView];
    
}

-(void)viewWillAppear:(BOOL)animated
{
    [self.tabBarController.tabBar setHidden:NO];
    
}

//建立CollectionView
-(void)CollectionView
{
    UICollectionViewFlowLayout * flowLayout = [[UICollectionViewFlowLayout alloc]init];
    
    [flowLayout setItemSize:CGSizeMake(360*D_width, 120*D_height)];
    
    [flowLayout setSectionInset:UIEdgeInsetsMake(7*D_height, 9*D_width, 8*D_height, 7*D_width)];
    
    flowLayout.minimumInteritemSpacing = 8;
    
    [flowLayout setMinimumLineSpacing:7];
    
    UICollectionView * CollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, kUIScreenWidth, kUIScreenHeight) collectionViewLayout:flowLayout];
    
    [CollectionView setDelegate:self];
    [CollectionView setDataSource:self];
    // [CollectionView setBackgroundColor:[UIColor whiteColor]];
    [CollectionView setBackgroundColor:RGBAColor(246, 246, 246, 1)];
    [CollectionView registerClass:[SecBarCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    
    [self.view addSubview:CollectionView];
}


-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return 5;
}
-(UICollectionViewCell * )collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    SecBarCollectionViewCell * cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    
    //  SecModel * mo = [_dataArray objectAtIndex:indexPath.row];
    
    [cell setBackgroundColor:[UIColor whiteColor]];
    return cell;
}

//CollectionView的点击方法
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    SecToViewController * secTo = [[SecToViewController alloc]init];
    
    [self.navigationController pushViewController:secTo animated:YES];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
